<!--
 * @FilePath     : /study_code/layui/19-2-1.html
 * @Description  : treetable-lay 渲染一个树表
 * @Date         : 2025-04-14 14:49:27
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-14 15:16:29
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
    <!-- css 是 treetable.js 中 js 代码追加 -->
  </head>
  <body>
    <table id="table1" class="layui-table" lay-filter="table1"></table>

    <script src="/layui/dist/layui.js"></script>
    <!-- <script src="/layui/treetable-lay/common.js"></script> -->
    <script>
      layui
        .config({
          base: '/layui/extends_modules',
        })
        .extend({
          treetable: '/treetable-lay/treetable',
        })
        .use(['form', 'treetable', 'layer'], function () {
          var layer = layui.layer,
            form = layui.form,
            $ = layui.jquery,
            treetable = layui.treetable

          treetable.render({
            elem: '#table1',
            treeColIndex: 1,
            treeSpid: -1,
            treeIdName: 'id',
            treePidName: 'pid',
            treeDefaultClose: true,
            treeLinkage: false,
            url: '/layui/treetable-lay/json/data.json',
            page: false,
            cols: [
              [
                { type: 'numbers' },
                { field: 'name', title: 'name' },
                { field: 'id', title: 'id' },
                { field: 'sex', title: 'sex' },
                { field: 'pid', title: 'pid' },
                { templet: '#oper-col', title: 'oper' },
              ],
            ],
            done: function () {
              layer.closeAll('loading')
            },
          })
        })
    </script>
  </body>
</html>
